var headSwiper = new Swiper('.headerSwiper',{
	pagination: {
	    el: '.swiper-pagination',
		clickable :true
	},
	autoplay:true,
	loop:true
});
var listSwiper = new Swiper('.list-swiper',{
	loop:true,
    pagination: {
        el: '.item-img-pagination',
        clickable: true,
        renderBullet: function (index, className) {
            switch(index){
                case 0:src='./images/about-icon.png';break;
                case 1:src='./images/center-icon.png';break;
                case 2:src='./images/intro-icon.png';break;
            }
            return '<div class="' + className + '" style="background-image: url('+ src +')"></div>';
        },
    },
})


function socialHeight(rNum){
	var socialSwiper = document.querySelectorAll(".social-swiper .swiper-container");
	var socialSwiperWrapper = document.querySelectorAll(".social-swiper .swiper-wrapper")
	for(var i =0;i<socialSwiper.length;i++){
		socialSwiperWrapper[i].style.height = socialSwiper[i].offsetHeight-rNum+'px'
	}
}



/* 判断是否移动端 */
if($(window).width()<992){
	window.onload=function(){
		toggleSwiper(50)
		socialHeight(50)
	}
	/* 改变轮播 */
	var socialSwiper1 = new Swiper('.socialSwiper1', {
	    slidesPerView: 1,
	    spaceBetween: 30,
	    navigation: {
	        nextEl: '.swiper-button-next',
	        prevEl: '.swiper-button-prev',
	    },
	});
	var socialSwiper2 = new Swiper('.socialSwiper2', {
	    slidesPerView: 1,
	    spaceBetween: 30,
	    navigation: {
	        nextEl: '.swiper-button-next',
	        prevEl: '.swiper-button-prev',
	    },
	});
	var socialSwiper3 = new Swiper('.socialSwiper3', {
	    slidesPerView: 1,
	    spaceBetween: 30,
	    navigation: {
	        nextEl: '.swiper-button-next',
	        prevEl: '.swiper-button-prev',
	    },
	});
	$(".foot-list h3").click(function(){
		$(this).next().toggle(200);
		$(this).find('span').toggleClass('active')
	})
}else if($(window).width()>992){
	window.onload=function(){
		socialHeight(80)
		toggleSwiper()
	}
	var socialSwiper1 = new Swiper('.socialSwiper1', {
	    slidesPerView: 4,
	    spaceBetween: 30,
	    navigation: {
	        nextEl: '.swiper-button-next',
	        prevEl: '.swiper-button-prev',
	    },
	});
	var socialSwiper2 = new Swiper('.socialSwiper2', {
	    slidesPerView: 4,
	    spaceBetween: 30,
	    navigation: {
	        nextEl: '.swiper-button-next',
	        prevEl: '.swiper-button-prev',
	    },
	});
	var socialSwiper3 = new Swiper('.socialSwiper3', {
	    slidesPerView: 4,
	    spaceBetween: 30,
	    navigation: {
	        nextEl: '.swiper-button-next',
	        prevEl: '.swiper-button-prev',
	    },
	});
}


var workExpertsSwiper = new Swiper('.swiper-work-experts',{
	slidesPerView: 3,
	spaceBetween: 30,
	autoplay:true,
	loop:true,
	navigation: {
	      nextEl: '.swiper-button-next',
	      prevEl: '.swiper-button-prev',
	}
})

/* 切换轮播图片 */
function toggleSwiper(hnum){
	$(".social-swiper .swiper-container").css("display","none")
	$(document).ready(function(){
	    var srcArr1 = ['./images/tabs-icon1.png','./images/tabs-icon2.png','./images/tabs-icon3.png']
	    var srcArr2 = ['./images/tabs-icon11.png','./images/tabs-icon21.png','./images/tabs-icon31.png']
	    $(".social-tabs").find("li").click(function () {
	        var index = $(this).index()
	        var imgSrc = $(this).find("img");
	        $.each($(".social-tabs li img"),function (key,val) {
	            val.src = srcArr1[key]
	            $(".social-swiper .swiper-container").removeClass("swiper-active")
	        })
	        imgSrc.attr("src",srcArr2[index])
	        $(".social-swiper .swiper-container").eq(index).addClass("swiper-active")
			socialHeight(hnum)
	    })
	});
}

/* 移动端导航 */
$(".icon-ul").click(function(){
	if($("nav").height()==276){
		$("nav").css("height","0")
		$(this).removeClass('active')
	}else{
		$("nav").css("height","276px")
		$(this).toggleClass('active')
	}
})
$(document).on("touchmove",function(){
	if($("nav").height()==276){
		$("nav").css("height","0")
		$(".icon-ul").removeClass('active')
	}
})
